import { a as u } from "./cookie.6dbf4ab5.js";
import { a as l } from "./axios.176b0184.js";
import "./__commonjsHelpers__.86354e3f.js";
import "./async-vendor.47a54775.js";
function c({ code: e, VUE_APP_BASE_API: r, token: t }) {
  return l({
    url: r + "/dictionary/getvaluelistbydiscode",
    method: "get",
    headers: {
      Authorization: `Bearer ${t}`
    },
    params: { code: e }
  }).then((o) => o.data);
}
function f(e) {
  try {
    return JSON.parse(e);
  } catch (r) {
    return console.error(r), null;
  }
}
const d = function(e) {
  var r = e && e.code, t = e && e.token, o = e && e.VUE_APP_BASE_API;
  if (!r)
    return null;
  var a = `dic.${r}`, s = u.get(a);
  return s && sessionStorage.getItem(a) ? Promise.resolve(f(sessionStorage.getItem(a))) : c({
    code: r,
    VUE_APP_BASE_API: o,
    token: t
  }).then((n) => n.data).then((n) => n ? n && n.length <= 0 ? Promise.resolve([]) : (n = n.map((i) => ({
    label: i.name,
    value: i.code + ""
  })), u.set(a, 1, { expires: 0.5 / 24 }), sessionStorage.setItem(a, JSON.stringify(n)), Promise.resolve(n)) : Promise.resolve([]));
};
function h(e = [], r) {
  var t = e.filter((o) => o.value == r);
  if (t && t[0])
    return t[0].label;
}
function A(e = [], r) {
  var t = e.filter((o) => o.value == r);
  if (t && t[0])
    return t[0];
}
export {
  d as ajaxDicList,
  A as getLabelOne,
  h as getLabelText
};
